package com.item.service;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.item.dao.NewsMapper;
import com.item.dao.model.News;
import com.item.dao.model.NewsExample;
import com.item.daoEx.NewsMapperEx;

@Service
public class NewsService {
    @Autowired
    private NewsMapper newsMapper;
    @Autowired
    private NewsMapperEx newsMapperEx;

    private static final Logger logger = Logger.getLogger(NewsService.class);

    public int countByExample(NewsExample example) {
        return this.newsMapper.countByExample(example);
    }

    public News selectByPrimaryKey(String id) {
        return this.newsMapper.selectByPrimaryKey(id);
    }

    public List<News> selectByExample(NewsExample example) {
        return this.newsMapper.selectByExample(example);
    }

    public int deleteByPrimaryKey(String id) {
        return this.newsMapper.deleteByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(News record) {
        return this.newsMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(News record) {
        return this.newsMapper.updateByPrimaryKey(record);
    }

    public int deleteByExample(NewsExample example) {
        return this.newsMapper.deleteByExample(example);
    }

    public int updateByExampleSelective(News record, NewsExample example) {
        return this.newsMapper.updateByExampleSelective(record, example);
    }

    public int updateByExample(News record, NewsExample example) {
        return this.newsMapper.updateByExample(record, example);
    }

    public int insert(News record) {
        return this.newsMapper.insert(record);
    }

    public int insertSelective(News record) {
        return this.newsMapper.insertSelective(record);
    }

    public int topDel(String id) {
    	return this.newsMapperEx.topDel(id);
    }
    
    public int topSet(News news) {
    	return this.newsMapperEx.topSet(news);
    }
    public int getMaxTopValue() {
    	int res = 0;
    	NewsExample example = new NewsExample();
    	int count = this.newsMapper.countByExample(example);
    	if(count > 0)
    		res =  this.newsMapperEx.getMaxTopValue();
    	return res;
    }
}